package com.jing.product.service.impl;

import com.jing.common.core.domain.R;
import com.jing.product.domain.po.Brand;
import com.jing.product.domain.po.ProductCategory;
import com.jing.product.domain.vo.BrandVO;
import com.jing.product.mapper.BrandMapper;
import com.jing.product.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：HaoYunde
 * @Package：com.jing.product.service.impl
 * @Project：Jing
 * @name：ProductServiceImpl
 * @Date：2024/5/23 14:44
 */
@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandMapper brandMapper;


    @Override
    public List<Brand> findBrandList(String name) {
        return brandMapper.findBrandList(name);
    }

    @Override
    public void delect(Integer id) {
        int flag=brandMapper.delect(id);
        if (flag==0){
            throw new RuntimeException("删除失败");
        }
    }

    @Override
    public void add(Brand brand) {
        int flag=brandMapper.add(brand);
        if (flag==0){
            throw new RuntimeException("添加失败");
        }
    }

    @Override
    public void update(Brand brand) {
        int flag=brandMapper.update(brand);
        if (flag==0){
            throw new RuntimeException("修改失败");
        }
    }

    @Override
    public void updateFactoryStatus(Integer id, Integer factoryStatus) {
        int flag=brandMapper.updateFactoryStatus(id,factoryStatus);
        if (flag==0){
            throw new RuntimeException("修改品牌制造商失败");
        }
    }

    @Override
    public void updateShowStatus(Integer id, Integer showStatus) {
        int flag=brandMapper.updateShowStatus(id,showStatus);
        if (flag==0){
            throw new RuntimeException("修改品牌是否显示");
        }
    }

    @Override
    public List<BrandVO> findALlBrand() {
        return brandMapper.findALlBrand();
    }
}
